package com.ruoyi.buss.qmcy.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.buss.qmcy.domain.QmcyCustLicaiSaleinfo;
import com.ruoyi.buss.qmcy.service.IQmcyCustLicaiSaleinfoService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 理财认购信息Controller
 * 
 * @author sxy
 * @date 2021-07-16
 */
@RestController
@RequestMapping("/saleInfo")
public class QmcyCustLicaiSaleinfoController extends BaseController
{
    @Autowired
    private IQmcyCustLicaiSaleinfoService qmcyCustLicaiSaleinfoService;

    /**
     * 查询理财认购信息列表
     */
    @PreAuthorize(hasPermi = "buss:saleInfo:list")
    @GetMapping("/list")
    public TableDataInfo list(QmcyCustLicaiSaleinfo qmcyCustLicaiSaleinfo)
    {
        startPage();
        List<QmcyCustLicaiSaleinfo> list = qmcyCustLicaiSaleinfoService.selectQmcyCustLicaiSaleinfoList(qmcyCustLicaiSaleinfo);
        return getDataTable(list);
    }

    /**
     * 导出理财认购信息列表
     */
    @PreAuthorize(hasPermi = "buss:saleInfo:export")
    @Log(title = "理财认购信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QmcyCustLicaiSaleinfo qmcyCustLicaiSaleinfo) throws IOException
    {
        List<QmcyCustLicaiSaleinfo> list = qmcyCustLicaiSaleinfoService.selectQmcyCustLicaiSaleinfoList(qmcyCustLicaiSaleinfo);
        ExcelUtil<QmcyCustLicaiSaleinfo> util = new ExcelUtil<QmcyCustLicaiSaleinfo>(QmcyCustLicaiSaleinfo.class);
        util.exportExcel(response, list, "理财认购信息数据");
    }

    /**
     * 获取理财认购信息详细信息
     */
    @PreAuthorize(hasPermi = "buss:saleInfo:query")
    @GetMapping(value = "/{prodcode}")
    public AjaxResult getInfo(@PathVariable("prodcode") String prodcode)
    {
        return AjaxResult.success(qmcyCustLicaiSaleinfoService.selectQmcyCustLicaiSaleinfoById(prodcode));
    }

    /**
     * 新增理财认购信息
     */
    @PreAuthorize(hasPermi = "buss:saleInfo:add")
    @Log(title = "理财认购信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QmcyCustLicaiSaleinfo qmcyCustLicaiSaleinfo)
    {
        return toAjax(qmcyCustLicaiSaleinfoService.insertQmcyCustLicaiSaleinfo(qmcyCustLicaiSaleinfo));
    }

    /**
     * 修改理财认购信息
     */
    @PreAuthorize(hasPermi = "buss:saleInfo:edit")
    @Log(title = "理财认购信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QmcyCustLicaiSaleinfo qmcyCustLicaiSaleinfo)
    {
        return toAjax(qmcyCustLicaiSaleinfoService.updateQmcyCustLicaiSaleinfo(qmcyCustLicaiSaleinfo));
    }

    /**
     * 删除理财认购信息
     */
    @PreAuthorize(hasPermi = "buss:saleInfo:remove")
    @Log(title = "理财认购信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{prodcodes}")
    public AjaxResult remove(@PathVariable String[] prodcodes)
    {
        return toAjax(qmcyCustLicaiSaleinfoService.deleteQmcyCustLicaiSaleinfoByIds(prodcodes));
    }
}
